package com.shrct.businessprocess.organization.impl;

import com.shrct.businessprocess.organization.RCEmployee;
import com.shrct.businessprocess.organization.RCEnterprise;
import com.shrct.businessprocess.organization.RCEnterpriseLocation;
import com.shrct.businessprocess.organization.impl.RCEmployeeImpl;
import com.shrct.businessprocess.organization.impl.RCEnterpriseLocationImpl;
import com.shrct.businessprocess.organization.proxy.RCEnterpriseProxy;
import edu.fudan.langlab.domain.organization.impl.PartyImpl;
import edu.fudan.mylang.pf.IObjectFactory;
import java.util.Collection;
import javax.persistence.CascadeType;
import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import org.eclipse.xtext.xbase.lib.Procedures.Procedure1;

@Entity
@DiscriminatorValue("RCENTERPRISE_TYPE")
public class RCEnterpriseImpl extends PartyImpl implements RCEnterprise {
  public RCEnterpriseImpl() {
    super();
  }
  
  public RCEnterpriseImpl(final RCEnterprise parent) {
    super();
    this.parent = parent;
  }
  
  private String code;
  
  public String getCode() {
    return this.code;
  }
  
  public RCEnterprise setCode(final String code) {
    this.code = code;
    return this;			
    
  }
  
  private String shortName;
  
  public String getShortName() {
    return this.shortName;
  }
  
  public RCEnterprise setShortName(final String shortName) {
    this.shortName = shortName;
    return this;			
    
  }
  
  private String ename;
  
  public String getEname() {
    return this.ename;
  }
  
  public RCEnterprise setEname(final String ename) {
    this.ename = ename;
    return this;			
    
  }
  
  private String spell;
  
  public String getSpell() {
    return this.spell;
  }
  
  public RCEnterprise setSpell(final String spell) {
    this.spell = spell;
    return this;			
    
  }
  
  private String helpCode;
  
  public String getHelpCode() {
    return this.helpCode;
  }
  
  public RCEnterprise setHelpCode(final String helpCode) {
    this.helpCode = helpCode;
    return this;			
    
  }
  
  private String enterpriseEnrolNum;
  
  public String getEnterpriseEnrolNum() {
    return this.enterpriseEnrolNum;
  }
  
  public RCEnterprise setEnterpriseEnrolNum(final String enterpriseEnrolNum) {
    this.enterpriseEnrolNum = enterpriseEnrolNum;
    return this;			
    
  }
  
  private String bank;
  
  public String getBank() {
    return this.bank;
  }
  
  public RCEnterprise setBank(final String bank) {
    this.bank = bank;
    return this;			
    
  }
  
  private String bankAccount;
  
  public String getBankAccount() {
    return this.bankAccount;
  }
  
  public RCEnterprise setBankAccount(final String bankAccount) {
    this.bankAccount = bankAccount;
    return this;			
    
  }
  
  private String workNo;
  
  public String getWorkNo() {
    return this.workNo;
  }
  
  public RCEnterprise setWorkNo(final String workNo) {
    this.workNo = workNo;
    return this;			
    
  }
  
  private Double regCapital;
  
  public Double getRegCapital() {
    return this.regCapital;
  }
  
  public RCEnterprise setRegCapital(final Double regCapital) {
    this.regCapital = regCapital;
    return this;			
    
  }
  
  private String legalPerson;
  
  public String getLegalPerson() {
    return this.legalPerson;
  }
  
  public RCEnterprise setLegalPerson(final String legalPerson) {
    this.legalPerson = legalPerson;
    return this;			
    
  }
  
  private String aptitudeName;
  
  public String getAptitudeName() {
    return this.aptitudeName;
  }
  
  public RCEnterprise setAptitudeName(final String aptitudeName) {
    this.aptitudeName = aptitudeName;
    return this;			
    
  }
  
  private String aptitudeNo;
  
  public String getAptitudeNo() {
    return this.aptitudeNo;
  }
  
  public RCEnterprise setAptitudeNo(final String aptitudeNo) {
    this.aptitudeNo = aptitudeNo;
    return this;			
    
  }
  
  private Boolean isBuildin = Boolean.valueOf(false);
  
  public Boolean getIsBuildin() {
    return this.isBuildin;
  }
  
  public RCEnterprise setIsBuildin(final Boolean isBuildin) {
    this.isBuildin = isBuildin;
    return this;			
    
  }
  
  @JoinColumn(name = "businessMan_id")
  @ManyToOne(targetEntity = RCEmployeeImpl.class, cascade = { CascadeType.MERGE, CascadeType.PERSIST })
  private RCEmployee businessMan;
  
  public RCEmployee getBusinessMan() {
    return this.businessMan;
  }
  
  public RCEnterprise setBusinessMan(final RCEmployee businessMan) {
    this.businessMan = businessMan;
    return this;			
    
  }
  
  @OneToMany(targetEntity = RCEnterpriseImpl.class, cascade = { CascadeType.MERGE, CascadeType.PERSIST, CascadeType.REMOVE }, mappedBy = "parent")
  private Collection<RCEnterprise> children = new java.util.ArrayList<com.shrct.businessprocess.organization.RCEnterprise>();;
  
  public Collection<RCEnterprise> getChildren() {
    return this.children;
  }
  
  public RCEnterprise createAndAddtoChildren() {
    getChildren().size();
    com.shrct.businessprocess.organization.RCEnterprise rCEnterprise = new com.shrct.businessprocess.organization.impl.RCEnterpriseImpl(this);
    getObjectFactory().create(rCEnterprise);
    getChildren().add(rCEnterprise);
    return rCEnterprise;
    
  }
  
  public RCEnterprise createAndAddtoChildren(final Procedure1<RCEnterprise> updater) {
    getChildren().size();
    com.shrct.businessprocess.organization.RCEnterprise rCEnterprise = new com.shrct.businessprocess.organization.impl.RCEnterpriseImpl(this);
    getObjectFactory().create(rCEnterprise);
    getChildren().add(rCEnterprise);
    return rCEnterprise;
    
  }
  
  public RCEnterprise removeAllChildren() {
    for(RCEnterprise obj : this.children){
    	getObjectFactory().delete(obj);
    }
    this.children.clear();
    return this;	
    
  }
  
  public RCEnterprise removeFromChildren(final RCEnterprise rCEnterprise) {
    this.children.remove(rCEnterprise);
    getObjectFactory().delete(rCEnterprise);
    return this;
    
  }
  
  @OneToMany(targetEntity = RCEnterpriseLocationImpl.class, cascade = { CascadeType.MERGE, CascadeType.PERSIST, CascadeType.REMOVE }, mappedBy = "enterprise")
  private Collection<RCEnterpriseLocation> locations = new java.util.ArrayList<com.shrct.businessprocess.organization.RCEnterpriseLocation>();;
  
  public Collection<RCEnterpriseLocation> getLocations() {
    return this.locations;
  }
  
  public RCEnterpriseLocation createAndAddtoLocations() {
    getLocations().size();
    com.shrct.businessprocess.organization.RCEnterpriseLocation rCEnterpriseLocation = new com.shrct.businessprocess.organization.impl.RCEnterpriseLocationImpl(this);
    getObjectFactory().create(rCEnterpriseLocation);
    getLocations().add(rCEnterpriseLocation);
    return rCEnterpriseLocation;
    
  }
  
  public RCEnterpriseLocation createAndAddtoLocations(final Procedure1<RCEnterpriseLocation> updater) {
    getLocations().size();
    com.shrct.businessprocess.organization.RCEnterpriseLocation rCEnterpriseLocation = new com.shrct.businessprocess.organization.impl.RCEnterpriseLocationImpl(this);
    getObjectFactory().create(rCEnterpriseLocation);
    getLocations().add(rCEnterpriseLocation);
    return rCEnterpriseLocation;
    
  }
  
  public RCEnterprise removeAllLocations() {
    for(RCEnterpriseLocation obj : this.locations){
    	getObjectFactory().delete(obj);
    }
    this.locations.clear();
    return this;	
    
  }
  
  public RCEnterprise removeFromLocations(final RCEnterpriseLocation rCEnterpriseLocation) {
    this.locations.remove(rCEnterpriseLocation);
    getObjectFactory().delete(rCEnterpriseLocation);
    return this;
    
  }
  
  @JoinColumn(name = "parent_id")
  @ManyToOne(targetEntity = RCEnterpriseImpl.class, cascade = { CascadeType.MERGE, CascadeType.PERSIST })
  private RCEnterprise parent;
  
  public RCEnterprise getParent() {
    return this.parent;
  }
  
  public RCEnterprise setParent(final RCEnterprise parent) {
    this.parent = parent;
    return this;			
    
  }
  
  public static RCEnterprise create(final RCEnterprise parent, final IObjectFactory objectFactory) {
    com.shrct.businessprocess.organization.RCEnterprise rCEnterprise = new com.shrct.businessprocess.organization.impl.RCEnterpriseImpl(
    	parent
    );
    objectFactory.create(rCEnterprise);
    return rCEnterprise;			
    
  }
  
  public static RCEnterprise createRCEnterpriseImpl(final RCEnterprise parent, final IObjectFactory objectFactory, final Procedure1<RCEnterprise> init) {
    com.shrct.businessprocess.organization.RCEnterprise rCEnterprise = new com.shrct.businessprocess.organization.impl.RCEnterpriseImpl(
    	parent
    );
    objectFactory.create(rCEnterprise);
    init.apply(rCEnterprise);
    
    return rCEnterprise;			
    
  }
  
  public RCEnterpriseProxy toProxy() {
    com.shrct.businessprocess.organization.proxy.RCEnterpriseProxy proxy = new com.shrct.businessprocess.organization.proxy.RCEnterpriseProxy();
    proxy.setId(this.getId());
    if(this instanceof edu.fudan.mylang.pf.INamedModelObject){
    	proxy.setName(((edu.fudan.mylang.pf.INamedModelObject)this).getEntityName());
    }
    return proxy;
    
  }
}
